#ifndef __TERMINAL_STATE_GRID_H__
#define __TERMINAL_STATE_GRID_H__

#include "wx/wx.h"
#include "wx/grid.h"
#include "wx/generic/gridctrl.h"

#define DEFAULT_TERM_STATE_GRID_COLS_NUM 32


class wxTermStateChangeEvent : public wxNotifyEvent
{
  DECLARE_DYNAMIC_CLASS(wxTermStateChangeEvent);    
 public:
  wxTermStateChangeEvent(){};
 wxTermStateChangeEvent(int r, int c,wxColour col,  wxEventType commandType = wxEVT_NULL,
		  int id = 0): wxNotifyEvent(commandType, id)
    {
      R = r;
      C = c;
      Col = col;
    }
 wxTermStateChangeEvent(const wxTermStateChangeEvent& event): wxNotifyEvent(event)
  {
    R=event.R;
    C=event.C;
    Col=event.Col;
  }
  virtual wxEvent *Clone() const
  { return new wxTermStateChangeEvent(*this); }
  int GetR(){return R;};
  int GetC(){return C;};
  wxColour GetCol(){return Col;};
 private:
  int R,C;
  wxColour Col;
};
typedef void (wxEvtHandler::*wxTermStateChangeEventFunction)
                                        (wxTermStateChangeEvent&);

//const wxEventType wxEVT_COMMAND_TERM_STATE_CHANGE = wxNewEventType();
BEGIN_DECLARE_EVENT_TYPES()
    DECLARE_EVENT_TYPE(wxEVT_COMMAND_TERM_STATE_CHANGE, -1)
END_DECLARE_EVENT_TYPES()

#define EVT_TERM_STATE_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY((const int&)wxEVT_COMMAND_TERM_STATE_CHANGE, -1, -1, \
  (wxObjectEventFunction) (wxEventFunction) (wxTermStateChangeEventFunction) & fn,\
  (wxObject *) NULL ),


class TerminalStateGrid: public wxGrid
{
public:
    TerminalStateGrid(wxWindow *parent, wxWindowID id, 
        const wxPoint& pos= wxDefaultPosition, 
        const wxSize& size= wxSize(100,100), 
        const long style=wxWANTS_CHARS);
    ~TerminalStateGrid();
    void InitTerms(int TermNum);
    void OnTermStateChange(wxTermStateChangeEvent& event);
private:    
    int TermLength;
    void OnLeftUp(wxGridEvent& event);
    void OnRightUp(wxGridEvent& event);
    DECLARE_EVENT_TABLE()
};

#endif

